package org.west.sky.frame.activiti.study.chapter14.demo0102;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.JavaDelegate;

/**
 * author: chz
 * date: 2025/3/20
 * description:
 */
public class CalculationUelFieldInjectedJavaDelegate implements JavaDelegate {

    private Expression inventoryResult;

    private Expression totalMoney;

    private Expression description;

    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("====开始计算");
        System.out.println("====描述：" + description.getValue(execution));
        Object inventoryResultValue = inventoryResult.getValue(execution);
        if ("库存不足".equals(inventoryResultValue)) {
            System.out.println("====库存不足");
            return;
        }
        execution.setVariable("totalMoney", totalMoney.getValue(execution));
    }

    public Expression getInventoryResult() {
        return inventoryResult;
    }

    public Expression getTotalMoney() {
        return totalMoney;
    }

    public Expression getDescription() {
        return description;
    }
}
